package job.work.controller.system;

import job.work.domain.response.CommonCode;
import job.work.domain.response.ResponseResult;
import job.work.domain.response.SafetyResponse;
import job.work.domain.system.entity.pojo.DecRole;
import job.work.domain.system.entity.pojo.dto.SignLoginUser;
import job.work.domain.system.entity.pojo.model.SystemUser;
import job.work.domain.system.request.MenuPageRequest;
import job.work.service.system.service.SystemService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import job.work.service.system.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 系统管理员对商家进行管理
 */
@RestController
@RequestMapping("/system")
@Api(tags ="用户登录模块")
@CrossOrigin
public class SystemController {

    @Autowired
    private SystemService systemService;

    @Resource
    UserService userService;

    @PostMapping("/saveUserPassword")
    @ApiOperation(value = "修改密码")
    @ApiImplicitParams({@ApiImplicitParam(name = "token", value = "Authorization token", required = true, dataType = "string", paramType = "header")})
    public ResponseResult saveUserPassword(@Validated @RequestBody SafetyResponse safetyRequestResponse) {
        if (safetyRequestResponse == null) {
            return new ResponseResult<>(CommonCode.PARAM_ERROR);
        }
        return systemService.saveUserPassword(safetyRequestResponse);
    }

    @GetMapping("/getInfo")
    @ApiOperation(value = "获取登录用户信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "token", value = "Authorization token", required = true, dataType = "string", paramType = "header")})
    public ResponseResult pickUpInformation() {
        return systemService.pickUpInformation();
    }

    @PostMapping("/signInUser")
    @ApiOperation(value = "注册账号")
    public ResponseResult signInUser(@Validated @RequestBody SignLoginUser signLoginUser) {
        return userService.signInUser(signLoginUser);
    }



}
